home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 20 / Cream of the Crop 20 (Terry Blount) (1996).iso / os2 / pine394.zip / misc / addff.c next >
C/C++ Source or Header  |  1996-04-17  |  683b  |  33 lines

  1. /*
  2.  * Simple filter program to add a final formfeed after
  3.  * a message stream. Output is to device or file given
  4.  * on the command line.
  5.  * David Nugent <davidn@unique.blaze.net.au>
  6.  * This code is public domain
  7.  */
  8.  
  9. #include <stdio.h>
  10.  
  11. int
  12. main (int argc, char *argv[])
  13. {
  14.   FILE * fp = stdout;
  15.   char tmp[1024];
  16.  
  17.   if (argc > 1 && (fp = fopen(argv[1], "w"))==NULL)
  18.   {
  19.     fprintf(stderr, "Can't open file/device '%s': %m\n", argv[1]);
  20.     return 1;
  21.   }
  22.  
  23.   /* Copy input to output */
  24.   while (fgets(tmp, sizeof tmp - 1, stdin)!=NULL)
  25.     fputs(tmp, fp);
  26.   /* Add the formfeed */
  27.   fputc('\f', fp);
  28.   /* Close and flush */
  29.   close(fp);
  30.  
  31.   return 0;
  32. }
  33.